package com.cat.test.test01;

import java.util.ArrayList;
import java.util.StringJoiner;
import java.util.stream.IntStream;

/**
 * @author 曲大人的喵
 * @description
 * @create 2025/10/28 11:49
 * @since JDK17
 */
record Hero(String name, int strength) { }
public class Solution05 {

    public static void main(String[] args) {
        // collect方法 : 两个参数 1. 创建容器 2. 向容器中添加元素的方法
        ArrayList<Integer> collect = IntStream.range(1, 11).collect(ArrayList::new, ArrayList::add, (a,b) -> {});
        System.out.println(collect);
        StringBuffer buffer = IntStream.range(1, 11).collect(StringBuffer::new, StringBuffer::append, (a, b) -> {
        });
        System.out.println(buffer);
        StringJoiner joiner = IntStream.range(1, 11).mapToObj(String::valueOf).collect(() -> new StringJoiner(","), StringJoiner::add, (a, b) -> {
        });
        System.out.println(joiner);

    }
}
